package net.wanho.test;

import net.wanho.entity.Teacher;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class test1 {
    public static void main(String[] args) throws IOException {
        String config="MybatisConfig.xml";
        //配置文件转化为流
        InputStream in= Resources.getResourceAsStream(config);
        SqlSessionFactory sf=new SqlSessionFactoryBuilder().build(in);
        //用工厂获取默认sqlSession对象
        SqlSession ss=sf.openSession();
        //使用sqlSession对象执行sql获取结果
        List<Teacher> list=ss.selectList("teacherDao.selectAll");
        System.out.println(list.size());
    }
}
